//example file for cjh_cv_image.h
#include "cvx_image.h"

using cvx_space::RgbImage;
using cvx_space::BwImage;

int main()
{
	IplImage *lenacolor = cvLoadImage("lena.jpg", 1);
	IplImage *lenagray= cvLoadImage("lena.jpg", 0);
	assert(lenacolor);
	assert(lenagray);

	cvShowImage("lenacolor", lenacolor);
	cvShowImage("lenagray", lenagray);
	int width = lenacolor->width;
	int height = lenacolor->height;
	//change the red and greed channel and overturn gray
	RgbImage col_img(lenacolor);
	BwImage  gra_img(lenagray);
	for (int y = 0; y<height; ++y) {
		for (int x = 0; x<width; ++x) {
			int r = col_img[y][x].r;
			int g = col_img[y][x].g;
			int b = col_img[y][x].b;

			col_img[y][x].r = g;
			col_img[y][x].g = r;
			gra_img[y][x] = 255 - gra_img[y][x];
		}
	}
	cvShowImage("lenacolor_", lenacolor);
	cvShowImage("lenagray_", lenagray);

	cvWaitKey(0);
	return 1;
	 
}